In [ ]:
In [2]:
import tensorflow as tf
import numpy
from matplotlib import image
from matplotlib import pyplot
%matplotlib inline
In [15]:
%reset
In [2]:
#basic python
x = 35
y = x + 5
print(y)
In [17]:
#basic TF
#x = tf.random_uniform([1, 2], -1.0, 1.0)
x = tf.constant(35, name = 'x')
y = tf.Variable(x+5, name = 'y')
model = tf.global_variables_initializer()
sess = tf.Session()
sess.run(model)
print(sess.run(y))
#per scrivere il grafo
#writer = tf.summary.FileWriter("output", sess.graph)
print(sess.run(y))
#writer.close
In [4]:
a = tf.add(1, 2,)
b = tf.multiply(a, 3)
c = tf.add(4, 5,)
d = tf.multiply(c, 6,)
e = tf.multiply(4, 5,)
f = tf.div(c, 6,)
g = tf.add(b, d)
h = tf.multiply(g, f)
primo = tf.constant(3, name = 'primo')
secondo = tf.constant(5, name = 'secondo')
somma1 = primo + secondo
somma2 = tf.add(primo, secondo)
sess = tf.Session()
#writer = tf.summary.FileWriter("output", sess.graph)
print(sess.run(h))
%time print(sess.run(somma1))
%time print(sess.run(somma2))
#writer.close
In [2]:
# Creates a graph.
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print(sess.run(c))
In [2]:
primo = tf.constant([[10,20,30], [100,200,300]], name = 'primo')
righe = tf.constant([1,2,3], name = 'secondo1')
colonne = tf.constant([[1],[2]], name = 'secondo2')
somma1 = primo + righe
somma2 = tf.add(primo, colonne)
sessione = tf.Session()
#writer = tf.summary.FileWriter("output", sess.graph)
print(sessione.run(somma1))
print(sessione.run(somma2))
print("dimensioni dei tre tensori")
print(primo.shape,
righe.shape,
colonne.shape)
print(primo)
In [8]:
# First, load the image
filename = "MarshOrchid.jpg"
img = tf.constant(image.imread(filename))
# Print out its shape
sessione = tf.Session()
numpimg = sessione.run(img)
pyplot.imshow(numpimg)
pyplot.show()
print(numpimg.size)
# immagine è resa come un array (non è chiaro se di numpy o di python)
In [10]:
alterazione = tf.constant([5,5,0], name='blur')
tensoreImg = tf.Variable(img+alterazione, name='x')
#print(tensoreImg)
model = tf.global_variables_initializer()
sess = tf.Session()
sess.run(model)
sess.run(tensoreImg)
img = tensoreImg.eval(session = sess)
img = img.astype(float)
#print(img)
pyplot.imshow(img)
#pyplot.show()
Out[10]:
In [2]:
# non ho ben capito cosa è Variable
#unitensor = tf.Variable(tf.ones((10,10)))
unitensor = tf.Variable(tf.ones((10,10)))
unitensor2 = tf.ones((10,10))
unitensor3 = tf.constant(1, shape=(10,10))
tritensor = tf.constant(3, shape=(10,10))
tritensor2 = tf.Variable(unitensor3*3)
init = tf.global_variables_initializer()
sessione = tf.Session()
sessione.run(init)
#print(sessione.run(unitensor))
#print(sessione.run(unitensor2))
print(sessione.run(unitensor3))
print(sessione.run(tritensor))
print(sessione.run(tritensor2))
In [117]:
rangetensor = tf.range(0, limit = 9, delta = 1)
rangeMatrTensor = tf.reshape(rangetensor, (3,3))
#transposeTensor = tf.transpose(rangetensor, perm=[1])
reshapeTensor = tf.reshape(rangetensor,(9,1))
init = tf.global_variables_initializer()
sessione = tf.Session()
sessione.run(init)
print(sessione.run(rangetensor))
print(sessione.run(rangeMatrTensor))
#print(sessione.run(transposeTensor))
print(sessione.run(reshapeTensor))
print(sessione.run(tf.ones(10, dtype = tf.int32)))
In [15]:
#tf.add #addizioni
#tf.subtract #sottrazioni
#tf.multiply #moltiplizazioni
#tf.scalar_mul(scalar, tensor) #aggiunge uno scalare a tutto il tensore
#tf.div #divisioni WARNING FORSE tf.divide È DIVERSO!
#tf.truediv #divisioni restituendo sempre float
unitensor = tf.ones((3,3))
duitensor = tf.constant(2.0, shape=(3,3))
sommatensor1 = tf.add(unitensor,duitensor)
sommatensor2 = tf.Variable(unitensor+duitensor)
init = tf.global_variables_initializer()
sessione = tf.Session()
sessione.run(init)
print(sessione.run(sommatensor1))
print(sessione.run(sommatensor2))
rangetensor = tf.range(0.0, limit = 9, delta = 1)
rangetensor = tf.reshape(rangetensor, (3,3))
prodottotensor1 = tf.multiply(rangetensor,duitensor)
# con variabile, non è esattamente la stessa cosa
prodottotensor2 = tf.Variable(rangetensor*duitensor)
init = tf.global_variables_initializer()
sessione = tf.Session()
sessione.run(init)
print(sessione.run(prodottotensor1))
print(sessione.run(prodottotensor2))
# le operazioni + e * lavorano elementwise come numpy, ma * può lavorare come prodotto scalare
In [84]:
#faccio prodotto vettoriale tra due vettori per ottenere matrice 2d, e poi faccio hack per ottenere matrice 3d
prodotto1 = tf.Variable(rangetensor*reshapeTensor)
#prodotto1 = tf.reshape(prodotto1, (81,1))
prodotto1bis = tf.multiply(rangetensor,reshapeTensor)
prodotto2 = tf.Variable(reshapeTensor*rangetensor)
prodotto2bis = tf.multiply(reshapeTensor, rangetensor)
#prodotto3d = tf.multiply(rangetensor,prodotto1) #che output dà questo comando?
#prodotto3d = tf.multiply(prodotto1, reshapeTensor) #è commutativo e dà stesso risultato sia che vettore sia
#verticale che orizzontale!
#prodotto3d = tf.multiply(rangetensor, prodotto1)
#prodotto3d = tf.reshape(prodotto3d, (9,9,9))
init = tf.global_variables_initializer()
sessione = tf.Session()
sessione.run(init)
def outer3d(vettore, matrice):
shape = tf.shape(matrice)
matrice = tf.reshape(matrice, (tf.size(matrice),1))
prodotto3d = tf.multiply(vettore, matrice)
return tf.reshape(prodotto3d, (shape[0],shape[1],tf.size(vettore)))
prodottoFunzione = outer3d(rangetensor,prodotto1)
#print(sessione.run(prodotto3d))
print(sessione.run(prodottoFunzione))
In [63]:
#prodotti matriciali
unitensor = tf.ones((3,3))
rangetensor = tf.range(0.0, limit = 9)
rangetensor = tf.reshape(rangetensor, (3,3))
tensorMatrProd = tf.matmul(rangetensor, rangetensor)
tensorProd = tf.tensordot(rangetensor,rangetensor, 1)
# sono equivalenti, se si fa il tensordot con asse 2 esce
# uno scalare che non capisco
sessione = tf.Session()
print(sessione.run(tensorMatrProd))
print(sessione.run(tensorProd))
print(sessione.run(tf.transpose(tensorProd)))
In [23]:
#tf.transpose #trasposta
#tf.reshape(rangetensor,(10,1)) #vettore trasposto
#tf.matrix_transpose #traposto di ultime due dimensioni un tensore di rango >=2
#tf.matrix_inverse #matrice inversa di quadrata, invertibile
tensoruni = tf.ones(10.0)
tensorzeri = tf.zeros(10.0)
tensorscala = tf.range(10.0)
colonne = tf.constant(10)
#prodotto scalare
tensorScalar = tf.tensordot(tensoruni,tensorscala, 1)
#trasposto
tensorTrasposto = tf.reshape(tensorscala,(10,1))
#outer: NB tensorFlow broadcasta automaticamente
tensorOuter = tensoruni*tensorTrasposto
sessione = tf.Session()
print(sessione.run(tensoruni), sessione.run(tensorzeri))
print(sessione.run(tf.zeros([colonne])))
print(sessione.run(tensorScalar))
print(sessione.run(tensorscala))
print(sessione.run(tensorTrasposto))
print(sessione.run(tensorOuter))
Tutte le operazioni matriciali:
https://www.tensorflow.org/api_guides/python/math_ops#Matrix_Math_Functions
https://www.tensorflow.org/api_docs/python/tf/tensordot (prodotto per contrazione di un indice)
In [14]:
array = tf.Variable(tf.range(10,20))
indici = tf.constant([1,3,5])
updati = tf.constant([100,90,4050])
slicearray = tf.gather(array,indici)
updarray = tf.scatter_update(array,indici,updati)
init = tf.global_variables_initializer()
sessione = tf.Session()
sessione.run(init)
print(sessione.run(array[0:4]))
print(sessione.run(slicearray))
print(sessione.run(array))
print(sessione.run(updarray))
In [7]:
# selezione nonzero elements
#vettore = tf.constant([1,0,0,2,0], dtype=tf.int64)
ravettore = tf.random_uniform((1,100000000),0,2,dtype = tf.int32)
ravettore = ravettore[0]
where = tf.not_equal(ravettore, 0)
indici = tf.where(where)
nonzeri = tf.gather(ravettore,indici)
#OPPURE
#sparso = tf.SparseTensor(indici, nonzeri, dense_shape=vettore.get_shape())
sessione = tf.Session(config=tf.ConfigProto(log_device_placement=True))
%time sessione.run(nonzeri)
#print(shape,sessione.run(shape))
#print(sessione.run(ravettore))
#%time print(sessione.run(indici))
#%time print(sessione.run(nonzeri))
#%time sessione.run(ravettore)
#%time sessione.run(indici)
#print(sessione.run(sparso))
In [9]:
from tensorflow.python.client import device_lib
def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
nomi = get_available_gpus()
print(nomi)
In [108]:
# prova map
sessione = tf.Session()
moltiplicatore = tf.range(10)
addizionatore = tf.range(100,110)
def mappalo(stepIesimo):
uni = tf.range(10)
moltiplicato = tf.multiply(moltiplicatore[stepIesimo],uni)
addizionato = moltiplicato + addizionatore
return addizionato
image = tf.map_fn(mappalo, tf.range(0, 10), dtype=tf.int32)
print(sessione.run(image))
In [18]:
#prova map con prodotto scalare
import numpy
from scipy import sparse
from matplotlib import pyplot
import tensorflow as tf
from tensorflow.python.client import timeline
import time
nRows = 10
def mapfunc(ithStep):
matrix1 = tf.zeros([1000,1000], dtype = tf.float32)
matrix2 = tf.ones([1000,1000], dtype = tf.float32)
matrix1 = tf.add(matrix1,ithStep)
prodotto = tf.matmul(matrix1,matrix2)
return prodotto
sessione = tf.Session(config=tf.ConfigProto(log_device_placement=True))
imageMapped = tf.map_fn(mapfunc, tf.range(0,nRows), dtype = tf.float32)
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
start = time.time()
image = sessione.run(imageMapped, options=run_options, run_metadata=run_metadata)
stop = time.time()
print(stop-start)
# Create the Timeline object, and write it to a json
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('timelineDB.json', 'w') as f:
f.write(ctf)
In [19]:
#prova prodotto scalare
import numpy
import tensorflow as tf
from tensorflow.python.client import timeline
matrix1 = tf.zeros([5000,5000], dtype = tf.int32)
matrix2 = tf.ones([5000,5000], dtype = tf.int32)
matrix1 = tf.add(matrix1,2)
product = tf.matmul(matrix1,matrix2)
session = tf.Session(config=tf.ConfigProto(log_device_placement=True))
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
image = session.run(product, options=run_options, run_metadata=run_metadata)
# Create the Timeline object, and write it to a json
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('timelineDB.json', 'w') as f:
f.write(ctf)
In [1]:
#prova histogram fixed
import numpy
import tensorflow as tf
from tensorflow.python.client import timeline
matrix1 = tf.random_uniform((5000,5000),0,2,dtype = tf.int32)
matrix2 = tf.ones([5000,5000], dtype = tf.int32)
matrix1 = tf.add(matrix1,2)
product = tf.matmul(matrix1,matrix2)
session = tf.Session(config=tf.ConfigProto(log_device_placement=True))
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
image = session.run(product, options=run_options, run_metadata=run_metadata)
# Create the Timeline object, and write it to a json
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('timelineDB.json', 'w') as f:
f.write(ctf)
In [1]:
import numpy
import tensorflow as tf
sessione = tf.Session()
array = tf.range(0,50)
kernel = tf.constant([1,1,1,1,1])
In [1]:
import numpy
import tensorflow as tf
sess = tf.Session()
array = numpy.array([0.1, 0.2, 0.4, 0.8, 0.9, 1.1]).astype(numpy.float32)
print(array.tobytes())
print(numpy.fromstring(array.tobytes()))
tensoraw = tf.constant(array.tobytes())
print(sess.run(tensoraw))
print(sess.run(tf.decode_raw(tensoraw, tf.float32)))
rawArray = sess.run(tensoraw)
decodedArray = sess.run(tf.decode_raw(tensoraw, tf.float32))
print(numpy.fromstring(rawArray))
print(numpy.fromstring(decodedArray))
cose utili o importanti
https://stackoverflow.com/questions/39219414/in-tensorflow-how-can-i-get-nonzero-values-and-their-indices-from-a-tensor-with
https://www.google.it/search?client=ubuntu&channel=fs&q=tf+scatter+update&ie=utf-8&oe=utf-8&gfe_rd=cr&ei=JkYvWduzO-nv8AfympmoAQ
https://stackoverflow.com/questions/34685947/adjust-single-value-within-tensor-tensorflow
https://www.tensorflow.org/versions/r0.11/api_docs/python/state_ops/sparse_variable_updates
https://www.tensorflow.org/api_docs/python/tf/scatter_add
https://www.tensorflow.org/api_docs/python/tf/scatter_update
https://stackoverflow.com/questions/34935464/update-a-subset-of-weights-in-tensorflow
https://stackoverflow.com/questions/39859516/how-to-update-a-subset-of-2d-tensor-in-tensorflow
In [45]:
#formalizzato in maniera generale come fare prodotto vettoriale tra due vettori e prodotto esterno vettore colonna-matrice
matrice = tf.reshape(tf.range(0,50), (10,5))
vettore = tf.range(0,4)
vettore1 = tf.range(1,6)
vettore2 = tf.range(100,106)
shape = tf.shape(matrice)
matrice = tf.reshape(matrice, (1, tf.size(matrice)))
vettore = tf.reshape(vettore, (tf.size(vettore),1))
prodotto3d = tf.multiply(vettore, matrice)
prodotto3d = tf.reshape(prodotto3d, (tf.size(vettore), shape[1],shape[0]))
vettore2 = tf.reshape(vettore2, (tf.size(vettore2),1))
prodottoX = tf.multiply(vettore1,vettore2)
sessione = tf.Session()
print(sessione.run(prodottoX))
#print(sessione.run(prodotto3d))
#print(sessione.run(shape))
In [73]:
# alcune altre prove su somme
vettore = tf.range(0,4)
vettore2 = tf.range(10,14)
sommaVettori = tf.add(vettore,vettore2)
vettoreSomma = vettore +2
vettoreSomma2 = tf.add(vettore,2)
vettoreSomma3 = tf.Variable(vettore+2)
init = tf.global_variables_initializer()
sessione = tf.Session()
sessione.run(init)
print(vettore, vettoreSomma, vettoreSomma2, vettoreSomma3)
print(sessione.run((vettore, vettoreSomma,vettoreSomma2,vettoreSomma3)))
print(sessione.run(sommaVettori))
In [207]:
# prova stack
vettore = tf.range(0,4)
vettore2 = tf.range(10,14)
vettore = tf.reshape(vettore,(1,4))
vettore2 = tf.reshape(vettore2,(1,4))
staccato = tf.stack([vettore[0],vettore2[0]])
sessione = tf.Session()
print(sessione.run(staccato))
In [268]:
# prova somma elementi con stesse coordinate in matrice sparsa
indices = tf.constant([[1, 1], [1, 2], [1, 2], [1, 6]])
values = tf.constant([1, 2, 3, 4])
# Linearize the indices. If the dimensions of original array are
# [N_{k}, N_{k-1}, ... N_0], then simply matrix multiply the indices
# by [..., N_1 * N_0, N_0, 1]^T. For example, if the sparse tensor
# has dimensions [10, 6, 4, 5], then multiply by [120, 20, 5, 1]^T
# In your case, the dimensions are [10, 10], so multiply by [10, 1]^T
linearized = tf.matmul(indices, [[10], [1]])
# Get the unique indices, and their positions in the array
y, idx = tf.unique(tf.squeeze(linearized))
# Use the positions of the unique values as the segment ids to
# get the unique values
values = tf.segment_sum(values, idx)
# Go back to N-D indices
y = tf.expand_dims(y, 1)
righe = tf.cast(y/10,tf.int32)
colonne = y%10
indices = tf.concat([righe, colonne],1)
tf.InteractiveSession()
print(indices.eval())
print(values.eval())
print(linearized.eval())
print(sessione.run((righe,colonne)))
In [39]:
# qui provo fully vectorial
sessione = tf.Session()
matrix = tf.random_uniform((10,10), 0,2, dtype= tf.int32)
coordinates = tf.where(tf.not_equal(matrix,0))
x = coordinates[:,0]
x = tf.cast(x, tf.float32)
times = coordinates[:,1]
times = tf.cast(times, tf.float32)
xSize = tf.shape(x)[0]
weights = tf.random_uniform((1,xSize),0,1,dtype = tf.float32)
nStepsY=5.0
y = tf.range(1.0,nStepsY+1)
#y = tf.reshape(y,(tf.size(y),1))
nRows = 5
nColumns = 80
image = tf.zeros((nRows, nColumns))
y = tf.reshape(y, (tf.size(y),1))
print(y[0])
yTimed = tf.multiply(y,times)
appoggio = tf.ones([nRows])
appoggio = tf.reshape(appoggio, (tf.size(appoggio),1))
#print(sessione.run(tf.shape(appoggio)))
#print(sessione.run(tf.shape(x)))
x3d = tf.multiply(appoggio,x)
weights3d = tf.multiply(appoggio,weights)
positions = tf.round(x3d-yTimed)
positions = tf.add(positions,50)
positions = tf.cast(positions, dtype=tf.int64)
riappoggio = tf.ones([xSize], dtype = tf.int64)
y = tf.cast(y, tf.int64)
y3d = tf.multiply(y, riappoggio)
y3d = tf.reshape(y3d, (1,tf.size(y3d)))
weights3d = tf.reshape(weights3d, (1,tf.size(weights3d)))
positions = tf.reshape(positions, (1,tf.size(positions)))
righe = y3d[0]
colonne = positions[0]
pesi = weights3d[0]
#VALUTARE DI FARE PARALLEL STACK
coordinate = tf.stack([righe,colonne],1)
shape = [6,80]
matrice = tf.SparseTensor(coordinate, pesi, shape)
matrice = tf.sparse_reorder(matrice)
coordinate = tf.cast(matrice.indices, tf.int32)
linearized = tf.matmul(coordinate, [[100], [1]])
coo, idx = tf.unique(tf.squeeze(linearized))
values = tf.segment_sum(matrice.values, idx)
# Go back to N-D indices
coo = tf.expand_dims(coo, 1)
indices = tf.concat([tf.cast(coo/100,tf.int32), coo%100],1)
#print(sessione.run((indices)))
#matrice = tf.SparseTensor(indices, pesi, shape)
immagine = tf.sparse_to_dense(indices, shape, values)
#print(sessione.run((tf.shape(coordinate), tf.shape(pesi), tf.shape(shape))))
#print(sessione.run((tf.shape(x3d), tf.shape(y3d),tf.shape(positions))))
#print(sessione.run(indices))
plottala = sessione.run(immagine)
%matplotlib inline
a = pyplot.imshow(plottala, aspect = 10)
#pyplot.show()
In [3]:
# qui provo mappando
sessione = tf.Session()
matrix = tf.random_uniform((10,10), 0,2, dtype= tf.int32)
coordinates = tf.where(tf.not_equal(matrix,0))
x = coordinates[:,0]
x = tf.cast(x, tf.float32)
times = coordinates[:,1]
times = tf.cast(times, tf.float32)
xSize = tf.shape(x)[0]
weights = tf.random_uniform((1,xSize),0,1,dtype = tf.float32)
nStepsY=5.0
y = tf.range(1.0,nStepsY+1)
#y = tf.reshape(y,(tf.size(y),1))
nRows = 5
nColumns = 80
weights = tf.reshape(weights, (1,tf.size(weights)))
pesi = weights[0]
def funmap(stepIesimo):
yTimed = tf.multiply(y[stepIesimo],times)
positions = tf.round(x-yTimed)
positions = tf.add(positions,50)
positions = tf.cast(positions, dtype=tf.int64)
positions = tf.reshape(positions, (1,tf.size(positions)))
riga= tf.ones([tf.size(x)])
riga = tf.reshape(riga, (1,tf.size(riga)))
righe = riga[0]
colonne = positions[0]
coordinate = tf.stack([tf.cast(righe,dtype=tf.int64),tf.cast(colonne,dtype=tf.int64)],1)
shape = [1,80]
matrice = tf.SparseTensor(coordinate, pesi, shape)
#matrice = tf.sparse_reorder(matrice)
coordinate = tf.cast(matrice.indices, tf.int32)
coo, idx = tf.unique(coordinate[:,1])
values = tf.segment_sum(matrice.values, idx)
immagine = tf.sparse_to_dense(coo, [nColumns], values)
#immagine = tf.cast(immagine, dtype=tf.float32)
return immagine
hough = tf.map_fn(funmap, tf.range(0,5),dtype=tf.float32)
plottala = sessione.run(hough)
print(numpy.size(plottala))
#imm = [plottala,plottala]
%matplotlib inline
a = pyplot.imshow(plottala, aspect = 10)
pyplot.show()
In [ ]:
# qui provo con tf map o scan (con bincount)
sessione = tf.Session()
matrix = tf.random_uniform((10,10), 0,2, dtype= tf.int32)
coordinates = tf.where(tf.not_equal(matrix,0))
x = coordinates[:,0]
x = tf.cast(x, tf.float32)
times = coordinates[:,1]
times = tf.cast(times, tf.float32)
xSize = tf.shape(x)[0]
weights = tf.random_uniform((1,xSize),0,1,dtype = tf.float32)
nStepsY=5.0
y = tf.range(1.0,nStepsY+1)
#y = tf.reshape(y,(tf.size(y),1))
nRows = 5
nColumns = 80
y = tf.reshape(y, (tf.size(y),1))
def mapIt(ithStep):
image = tf.zeros(nColumns)
yTimed = y[ithStep]*times
positions = tf.round(x-yTimed+50, dtype=tf.int32)
values = tf.bincount(positions,weights)
values = values[numpy.nonzero(values)]
positions = numpy.unique(positions)
image[positions] = values
return image
%time imageMapped = list(map(mapIt, range(nStepsY)))
imageMapped = numpy.array(imageMapped)
%matplotlib inline
a = pyplot.imshow(imageMapped, aspect = 10)
In [21]:
import scipy.io
import numpy
percorsoFile = "/home/protoss/matlabbo.mat"
#percorsoFile = "matlabbo/miaimgSenzacumsum.mat"
scalareMatlabbo = scipy.io.loadmat(percorsoFile)['scalarevero']
In [22]:
scalareMatlabbo
Out[22]:
In [18]:
ncolumn = tf.constant(10)
matrice = tf.zeros((0,ncolumn))
print(sessione.run(matrice))
In [ ]: